﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditCommunity.aspx.cs" Inherits="EditCommunity"
    MasterPageFile="~/Master.master" %>

<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxCallbackPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxTreeList.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeList" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2.Linq, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Data.Linq" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="Server">
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language="javascript">
        function showinfo(Control) {
            PPanel.ShowAtElement(Control);
        }
        function showStreet(Control) {
            PPanelStreet.ShowAtElement(Control);
        }
        function showCommunity(Control) {
            PPanelCommunity.ShowAtElement(Control);
        }
        function showCity(Control) {
            PPanelCity.ShowAtElement(Control);
        }
        //选择城区
        function selectCity(cmdCity) {
            CStreet.PerformCallback(cmdCity.GetValue().toString());
        }
        //选择街道
        function selectStreet() {

        }
//        function OnFousFun(element1, element2, text) {
//            if ($(element1).val() == "" || $(element1).val() == text) {//输入框里值为空，或者为一些特定的文字时，都提示输入不能为空
//                $(element2).html("输入不能为空");
//                return false;
//            }
//            else {
//                $(element2).html("");
//                return true;
//            }

//        }

    </script>
    <h1 class="DemoTitle">
        社区信息管理
    </h1>
    <div id="DemoArea">
        <div style="width: 100%">
            <dx:ASPxPanel ID="ASPxPanel1" runat="server" Width="100%">
                <PanelCollection>
                    <dx:PanelContent>
                        <table width="100%">
                            <tr>
                                <td class="style1">
                                    <a href="#" onclick="javascript:showCity(this)">添加城区</a>
                                </td>
                                <td class="style2">
                                    <a href="#" onclick="javascript:showStreet(this)">添加街道</a>
                                </td>
                                <td>
                                    <a href="#" onclick="javascript:showCommunity(this)">添加社区</a>
                                </td>
                            </tr>
                        </table>
                    </dx:PanelContent>
                </PanelCollection>
            </dx:ASPxPanel>
        </div>
        <div class="Spacer" style="height: 14px;">
        </div>
        <dx:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server" Width="100%" ClientInstanceName="QueryPanel">
            <PanelCollection>
                <dx:PanelContent SupportsDisabledAttribute="True" runat="server">
                    <dx:ASPxTreeList ID="DXTreelist" runat="server" AutoGenerateColumns="False" ClientInstanceName="QueryTree"
                        Width="100%" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue"
                        KeyFieldName="Community_ID" ParentFieldName="Parent_ID" OnNodeDeleting="DXTreelist_NodeDeleting"
                        OnNodeUpdating="DXTreelist_NodeUpdating" OnCustomDataCallback="DXTreelist_CustomDataCallback"
                        Style="margin-top: 0px">
                        <ClientSideEvents CustomDataCallback="function(s, e) { 
                         var key = QueryTree.GetFocusedNodeKey();
                         var city = document.getElementById('txtcityshow');
                         var street = document.getElementById('txtstreetshow');
                                           
                         if(key.length == 2)
                         {
                           city.innerHTML = e.result;
                           lblcityids.SetText(key);
                           street.innerHTML = '请选择街道';
                           
                         }
                         if(key.length == 4)
                         {
                            street.innerHTML = e.result;
                            lblstreetids.SetText(key);
                            city.innerHTML ='请选择城区';
                         }
                        }" FocusedNodeChanged="function(s, e) { 
                        var key = QueryTree.GetFocusedNodeKey();
                        QueryTree.PerformCustomDataCallback(key); 

                        }" />
                        <Columns>
                            <dx:TreeListTextColumn Caption="社区编号" FieldName="Community_ID" VisibleIndex="0">
                            </dx:TreeListTextColumn>
                            <dx:TreeListTextColumn Caption="社区名称" FieldName="Community_Name" VisibleIndex="1">
                            </dx:TreeListTextColumn>
                            <dx:TreeListCommandColumn Name="treeCommand" ShowNewButtonInHeader="true" VisibleIndex="2">
                                <EditButton Visible="True">
                                </EditButton>
                                <DeleteButton Visible="True">
                                </DeleteButton>
                            </dx:TreeListCommandColumn>
                        </Columns>
                        <Settings SuppressOuterGridLines="True" />
                        <SettingsBehavior AllowFocusedNode="True" AutoExpandAllNodes="true" />
                        <SettingsPager Mode="ShowPager" PageSize="20">
                            <Summary Text="当前第{0}页，共{1}页，{2}条记录" />
                        </SettingsPager>
                        <SettingsSelection Enabled="True" Recursive="True" />
                        <SettingsEditing Mode="EditFormAndDisplayNode" />
                        <SettingsText CommandCancel="关闭" CommandDelete="删除" CommandEdit="编辑" CommandNew="新增"
                            CommandUpdate="更新" ConfirmDelete="确定要删除吗？" RecursiveDeleteError="该节点有子节点，请先删除其子节点" />
                        <Images SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
                            <LoadingPanel Url="~/App_Themes/Office2010Blue/TreeList/Loading.gif">
                            </LoadingPanel>
                        </Images>
                        <Styles CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue">
                            <LoadingPanel ImageSpacing="5px">
                            </LoadingPanel>
                        </Styles>
                        <StylesPager>
                            <PageNumber ForeColor="#3E4846">
                            </PageNumber>
                            <Summary ForeColor="#1E395B">
                            </Summary>
                        </StylesPager>
                        <StylesEditors ButtonEditCellSpacing="0">
                        </StylesEditors>
                    </dx:ASPxTreeList>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxCallbackPanel>
        <dx:ASPxPopupControl ID="ASPxPopupControl1" runat="server" Width="650px" ClientInstanceName="PPanelStreet"
            CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css" CssPostfix="Office2010Silver"
            EnableHotTrack="False" SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css"
            HeaderText="街道添加">
            <LoadingPanelImage Url="~/App_Themes/Office2010Silver/Web/Loading.gif">
            </LoadingPanelImage>
            <LoadingPanelStyle ImageSpacing="5px">
            </LoadingPanelStyle>
            <ContentCollection>
                <dx:PopupControlContentControl>
                    <table width="100%">
                        <tr>
                            <td>
                                所属城区：
                            </td>
                            <td>
                                <span id="txtcityshow">
                                    <dx:ASPxLabel ID="lblcity" runat="server" Text="">
                                    </dx:ASPxLabel>
                                </span>
                            </td>
                            <td>
                                城区编号：
                            </td>
                            <td>
                                <dx:ASPxLabel ID="lblcityid"  ClientInstanceName="lblcityids" runat="server" Text="">
                                </dx:ASPxLabel>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                街道编号：
                            </td>
                            <td>
                                <span id="txtStreetIDs">
                                    <dx:ASPxTextBox ID="txtStreetID" ClientInstanceName="getstreet" runat="server" Width="170px">
                                    </dx:ASPxTextBox>
                                </span>
                            </td>
                            <td>
                                街道名称：
                            </td>
                            <td>
                                <dx:ASPxTextBox ID="txtStreetName" runat="server" Width="170px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td align="right">
                                <dx:ASPxButton ID="btnStreetAdd" runat="server" Text="更新" CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css"
                                    CssPostfix="Office2010Silver" SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css"
                                    Font-Size="10pt" OnClick="btnStreetAdd_Click">
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </dx:PopupControlContentControl>
            </ContentCollection>
        </dx:ASPxPopupControl>
        <dx:ASPxPopupControl ID="ASPxPopupControl2" runat="server" Width="700px" CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css"
            CssPostfix="Office2010Silver" EnableHotTrack="False" HeaderText="添加社区" SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css"
            ClientInstanceName="PPanelCommunity">
            <LoadingPanelImage Url="~/App_Themes/Office2010Silver/Web/Loading.gif">
            </LoadingPanelImage>
            <LoadingPanelStyle ImageSpacing="5px">
            </LoadingPanelStyle>
            <ContentCollection>
                <dx:PopupControlContentControl>
                    <table width="100%">
                        <tr>
                            <td>
                                所属街道:
                            </td>
                            <td>
                                <span id="txtstreetshow">
                                    <%--<dx:ASPxTextBox ID="txtStreet" runat="server" Width="170px" CssFilePath="~/App_Themes/DevEx/{0}/styles.css"
                                        CssPostfix="DevEx" SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css">
                                    </dx:ASPxTextBox>--%>
                                    <dx:ASPxLabel ID="lblStreet" runat="server" Text="">
                                    </dx:ASPxLabel>
                                </span>
                            </td>
                            <td>
                              街道编号：
                            </td>
                            <td>
                                <dx:ASPxLabel ID="lblstreetid" runat="server" ClientInstanceName="lblstreetids" Text="">
                                </dx:ASPxLabel>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                社区编号：
                            </td>
                            <td>
                                <span id="txtCommunityIDs">
                                    <dx:ASPxTextBox ID="txtCommunityID" ClientInstanceName="getcommunity" runat="server" Width="170px">
                                    </dx:ASPxTextBox>
                                </span>
                            </td>
                            <td>
                                社区名称：
                            </td>
                            <td>
                                <dx:ASPxTextBox ID="txtCommunityName" runat="server" Width="170px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td align="right">
                                <dx:ASPxButton ID="btnOKCommunity" runat="server" Text="更新" CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css"
                                    CssPostfix="Office2010Silver" SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css"
                                    Font-Size="10pt" OnClick="btnOKCommunity_Click">
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </dx:PopupControlContentControl>
            </ContentCollection>
        </dx:ASPxPopupControl>
        <dx:ASPxPopupControl ID="ASPxPopupControl3" runat="server" Width="650px" ClientInstanceName="PPanelCity"
            CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css" CssPostfix="Office2010Silver"
            EnableHotTrack="False" HeaderText="添加城区" SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css">
            <LoadingPanelImage Url="~/App_Themes/Office2010Silver/Web/Loading.gif">
            </LoadingPanelImage>
            <LoadingPanelStyle ImageSpacing="5px">
            </LoadingPanelStyle>
            <ContentCollection>
                <dx:PopupControlContentControl>
                    <table width="100%">
                        <tr>
                            <td>
                                城区编号：
                            </td>
                            <td>
                                <dx:ASPxTextBox ID="txtCityID" runat="server" Width="170px">
                                </dx:ASPxTextBox>
                            </td>
                            <td>
                                城区名称：
                            </td>
                            <td>
                                <dx:ASPxTextBox ID="txtCityName" runat="server" Width="170px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td align="right">
                                <dx:ASPxButton ID="btnAddCity" runat="server" Text="更新" CssFilePath="~/App_Themes/Office2010Silver/{0}/styles.css"
                                    CssPostfix="Office2010Silver" SpriteCssFilePath="~/App_Themes/Office2010Silver/{0}/sprite.css"
                                    Font-Size="10pt" OnClick="btnAddCity_Click">
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                </dx:PopupControlContentControl>
            </ContentCollection>
        </dx:ASPxPopupControl>
        <dx:LinqServerModeDataSource ID="LSMDCom" runat="server" ContextTypeName="DAL.DataClassesDataContext"
            EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Community" />
    </div>
</asp:Content>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="head">
    <style type="text/css">
        #QueryTable
        {
            width: 233px;
        }
        .style1
        {
            width: 101px;
        }
        .style2
        {
            width: 95px;
        }
    </style>
</asp:Content>
